'use strict';

var mongoose = require('mongoose'),
    Schema = mongoose.Schema,
    baseController = require('../../../Base/server/controllers/BaseDoc.js');

var newModel = baseController.getBaseDocFields();
//单号
newModel.Code = {
    type: String,
    unique: '编码已存在',
    required: '请输入编码',
    trim: true
};
//批号
newModel.LotNumber = {
    type: String,
    trim: true
};
//物料
newModel.ItemMaster = {
    type: Schema.ObjectId,
    ref: 'ItemMaster'
};
//生产数量
newModel.Qty = {
    type: Number,
    required: '请输入生产数量'
};
//完工日期
newModel.CompleteTime = {
    type: Date
};
//完工量
newModel.CompleteQty = {
    type: Number
};
//状态 0: 开工 1：完工
newModel.Status = {
    type: Number
};
newModel.Remark = {
    type: String,
    default: '',
    trim: true
};
//ERP ID
newModel.ErpId = {
    type: String,
    trim: true
};

var newSchema = new Schema(newModel);
newSchema.index({ItemMaster: 1, Code: 1});

mongoose.model('CompletePlan', newSchema, 'CompletePlan');
